import 'package:flutter/material.dart';
/// CreateTime 2020/4/27 20:16
/// CreateUser chen 
/// ProjectName tatoxApp
import 'package:flutter/widgets.dart';
import 'package:shimmer/shimmer.dart';


class SpinKitFoldingCube extends StatefulWidget{
  double size;
  Color color;
  SpinKitFoldingCube({this.size = 50,this.color = Colors.white});

  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _SpinkitFoldingCubeState();
  }
}

class _SpinkitFoldingCubeState extends State<SpinKitFoldingCube>{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Shimmer.fromColors(
        direction: ShimmerDirection.ltr,
        child: Image.asset('images/logo_png.png',height: widget.size,width: widget.size,),
        baseColor: Color(0xffffcd36),
        highlightColor: Colors.white,
//        enabled: true,
        loop: 0,
//        period: Duration(microseconds: 1800),
    );
  }

}




//class SpinKitFoldingCube extends StatefulWidget {
//  const SpinKitFoldingCube({
//    Key key,
//    this.color = Colors.white,
//    this.size = 50.0,
//    this.itemBuilder,
//    this.duration = const Duration(milliseconds: 1400),
//    this.controller,
//  })  : assert(!(itemBuilder is IndexedWidgetBuilder && color is Color) && !(itemBuilder == null && color == null),
//  'You should specify either a itemBuilder or a color'),
//        assert(size != null),
//        super(key: key);
//
//  final Color color;
//  final double size;
//  final IndexedWidgetBuilder itemBuilder;
//  final Duration duration;
//  final AnimationController controller;
//
//  @override
//  _SpinKitFoldingCubeState createState() => _SpinKitFoldingCubeState();
//}
//
//class _SpinKitFoldingCubeState extends State<SpinKitFoldingCube> with SingleTickerProviderStateMixin {
//  AnimationController _controller;
//  Animation<double> _rotate1, _rotate2, _rotate3, _rotate4;
//  int status = 1;
//  @override
//  void initState() {
//    super.initState();
//
//    _controller = (widget.controller ?? AnimationController(vsync: this, duration: widget.duration))
//      ..addListener((){
//        if(_controller.status == AnimationStatus.completed){
//          if(status % 2 == 1){
//            _controller.reverse();
//          }else{
//            _controller.forward();
//          }
//          print(status);
//          status++;
//        }
//        setState(() {});
//      } )..forward()..repeat(reverse: true);
////      ..repeat(reverse: true);
//    _rotate1 = Tween(begin: 0.0, end: 180.0)
//        .animate(CurvedAnimation(parent: _controller, curve: const Interval(0.0, 0.25, curve: Curves.easeIn)));
//
//    _rotate2 = Tween(begin: 0.0, end: 180.0)
//        .animate(CurvedAnimation(parent: _controller, curve: const Interval(0.25, 0.5, curve: Curves.easeIn)));
//
//    _rotate3 = Tween(begin: 0.0, end: 180.0)
//        .animate(CurvedAnimation(parent: _controller, curve: const Interval(0.5, 0.75, curve: Curves.easeIn)));
//
//    _rotate4 = Tween(begin: 0.0, end: 180.0)
//        .animate(CurvedAnimation(parent: _controller, curve: const Interval(0.75, 1.0, curve: Curves.easeIn)));
//  }
//
//  @override
//  void dispose() {
//    _controller.dispose();
//    super.dispose();
//  }
//
//  @override
//  Widget build(BuildContext context) {
//    return Center(
//      child: SizedBox.fromSize(
//        size: Size.square(widget.size),
//        child: Center(
//          child: Stack(
//            children: <Widget>[
//              Positioned(
//                  left: 0,
//                  top: 0,
//                  bottom: 0,
//                  child: _img(1, animation: _rotate2)),
//              Positioned(
//                  right: 0,
//                  top: 0,
//                  bottom: 0,
//                  child: _img(2, animation: _rotate3)),
//              Positioned(
//                  right: widget.size / 8 * 3,
//                  left: widget.size / 8 * 3,
//                  bottom: 0,
//                  child: _img(3, animation: _rotate4)),
//            ],
//          ),
////          child: Transform.rotate(
////            angle: -45.0 * 0.0174533,
////            child: Stack(
////              children: <Widget>[
////                _cube(1, animation: _rotate2),
////                _cube(2, animation: _rotate3),
//////                _cube(4, animation: _rotate4),
////                _cube(3, animation: _rotate1),
////              ],
////            ),
////          ),
//        ),
//      ),
//    );
//  }
//
//  Widget _img(int i, {Animation<double> animation}){
//    Widget img ;
//    switch(i){
//      case 1:
//        img = Image.asset(R.assetsImageLogoLogoLeftPng,height: widget.size,width: widget.size/2,);
//        break;
//      case 2:
//        img = Image.asset(R.assetsImageLogoLogoRightPng,height: widget.size,width: widget.size/2,);
//        break;
//      case 3:
//        img = Image.asset(R.assetsImageLogoLogoCenterPng,height: widget.size/4,width: widget.size/4,);
//        break;
//      default:
//    }
//    return Opacity(
//      opacity: 1.0 - (animation.value / 180.0),
//      child: img,
//    );
//  }
//
//  Widget _cube(int i, {Animation<double> animation}) {
//    final _size = widget.size * 0.5, _position = widget.size * .5;
//
//    final Matrix4 _tRotate = Matrix4.identity()..rotateY(animation.value * 0.0174533);
//    Widget img = Image.asset(R.assetsImageLogoLogoLeftPng);
//    switch(i){
//      case 1:
//        img = Image.asset(R.assetsImageLogoLogoRightPng,height: widget.size,width: widget.size/2,);
//        break;
//      case 2:
//        img = Image.asset(R.assetsImageLogoLogoCenterPng,height: widget.size,width: widget.size/2,);
//        break;
//      case 3:
//        img = Image.asset(R.assetsImageLogoLogoLeftPng,height: widget.size/4,width: widget.size/4,);
//        break;
//      default:
//    }
//
//    return Positioned.fill(
//      top: _position,
//      left: _position,
//      child: Transform(
//        transform: Matrix4.rotationZ(90.0 * (i - 1) * 0.0174533),
//        child: Align(
//          alignment: Alignment.center,
//          child: Transform(
//            transform: _tRotate,
//            alignment: Alignment.centerLeft,
//            child: Opacity(
//              opacity: 1.0 - (animation.value / 180.0),
//              child: SizedBox.fromSize(
//                size: Size.square(_size),
//                child: _itemBuilder(i - 1),
//              ),
//            ),
//          ),
//        ),
//      ),
//    );
//  }
//
//  Widget _itemBuilder(int index) => widget.itemBuilder != null
//      ? widget.itemBuilder(context, index)
//      : DecoratedBox(decoration: BoxDecoration(color: widget.color));
//}

